package ai.george.mcpclient.controller;


import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "高德地区的mcp示例")
@RestController
@RequestMapping("/amap-mcp")
public class AmapMcpController {


    private final ChatClient chatClient;

    public AmapMcpController(ChatClient.Builder builder, ToolCallbackProvider toolCallbackProvider) {

        this.chatClient = builder
                .defaultOptions(DashScopeChatOptions.builder().withTemperature(0.7).build())
                .defaultToolCallbacks(toolCallbackProvider.getToolCallbacks()) // 添加工具回调
                .build();
    }


    /**
     *  高德地图mcp
     * @param question
     * @return
     */
    @GetMapping("/agent")
    public String ragQuery(@RequestParam(name = "question") String question) {

        // 杭州市天气怎么样呀
        // 从120.035609,30.287132到119.992937,30.228932怎么走

        // 该chatClient已经配备了RAG能力
        return chatClient
                .prompt()
                .system("你是一个出行小助手，请根据用户问题进行作答")
                .user(question)
                .call()
                .content();
    }



}
